import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'


import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';


// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(),
  AutoImport({
    resolvers: [VantResolver()],
  }),
  Components({
    resolvers: [VantResolver()],
  }),],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
  server: {
    proxy: {
      '/dev': {
        target: 'https://apis.netstart.cn/mbcomic',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev/, ''),
      },
      '/proxy-image': {
        target: ' https://i0.hdslb.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/proxy-image/, ''),
        headers: {
          Referer: ' https://i0.hdslb.com', // 设置合法的 Referer
        }
      },
    },
  },
  esbuild: {
    drop: ['console', 'debugger'],
  }
})
